﻿using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Data;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class TSJDWB
    {
        public TSJDWB()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_STOCK();
            this.DataContext = MV;
            InitializeComponent(); 
        }
        public override void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            base.bgWorker_RunWorkerCompleted(sender, e);
            vwMaster.View.MoveCurrentTo(-1);
            EventDispatcher.Instance.RaiseStatus("完成数据更新", StatusEventType.StopProgress);
        }

        public override void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            base.bgWorker_DoWork(sender, e);
            EventDispatcher.Instance.RaiseStatus("开始更新数据", StatusEventType.RunningProgress);
            TMV.EXEWI09(PM["DTSTART"], "F");

        }
        public void FilterMaster_Click(object sender, RoutedEventArgs e)
        {
            string filter = "ART LIKE '%" + ART.Trim() + "%' AND FARBE LIKE '" + FARBE.Trim() + "%' AND FINISH LIKE '%" + FINISH.Trim() + "%'";
            cvMaster.CustomFilter = filter;
        }

        public void FilterMasterClear_Click(object sender, RoutedEventArgs e)
        {

            cvMaster.CustomFilter = null;
        }
        public override void NewCommand(object sender, RoutedEventArgs e)
        {
            PM["DTSTART"] = DTSTART;
            bgWorker.RunWorkerAsync();
            Tracer.Info("", "已经更新完成");
             base.NewCommand(sender, e); 
        }

        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            SResult = TMV.LoadStock(DTSTART, LO, LB, ART, VAR);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        }

        private  void PrintCommand(object sender, RoutedEventArgs e)
        {

        }

    }
}
